	var id = GetQueryString("id");
	var vm = new Vue({
    	  el: '#app',
    	  data: {
			  data1: {
			            id:"",
              			beginTime: "",
              			endTime: ""
              		}
    	  },
    	  methods: {
    	        getGroupInfo() {
    	            $.get(baseURL + '/sys/groupInfo/info?id=' + id, function(data) {
    	                if(data.code != 0) {
    	                    layer.msg('获取分组信息失败');
    	                    return ;
    	                }
    	                vm.data1 = data.groupInfo;
    	            });
    	        },
    	        saveOrUpdate: function () {
    	            var beginTime = $('#daterange1').val();
    	            var endTime = $('#daterange2').val();
    	            vm.data1.beginTime = beginTime;
    	            vm.data1.endTime = endTime;
    	            vm.data1.id = id;
    	    	  var url = "/sys/groupInfo/edit";
    				$.ajax({
    					type: "POST",
    				    url: baseURL + url,
    				    contentType: "application/json",
                        data: JSON.stringify(vm.data1),
    				    success: function(r){
    				    	if(r.code === 0){
    				    		layer.alert('提交成功', function(index){
    				    			backToTable();
    				    			layer.close(index);
    							});
    						}else{
    							layer.alert(r.msg);
    						}
    					}
    				});
    	      }
    	  },
    	  mounted:function(){
    	    this.getGroupInfo();
    	  }
    });
	
	//表单验证
	$(function() {
        $("#editForm").validate({
            rules: {
                daterange1: "required"

            },
            messages: {
                daterange1: "请输入开始时间"
            },
            submitHandler : function(form) {  //验证通过后的执行方法
                //当前的form通过ajax方式提交
                vm.saveOrUpdate();
            },
            /* 重写错误显示消息方法,以tips方式弹出错误消息 */
            showErrors: function(errorMap, errorList) {
                var msg = "";
                $.each( errorList, function(i,v){
                  msg = (v.message+"\r\n");
                  if(msg!="") layer.tips(msg, "#"+v.element.id, { tips:2, tipsMore: true });
                });
            },
            /* 提示失去焦点时不验证 */
            onfocusout: false
        });

    });
    
        
        laydate.render({
            elem: '#daterange1',
            type: 'datetime'
        });

        laydate.render({
            elem: '#daterange2',
            type: 'datetime'
        });